import uniqueId from "@form-create/utils/lib/unique";
import { localeProps, makeRequiredRule } from "../../utils";

const label = "评分";
const name = "rate";

export default {
  icon: "icon-rate",
  label,
  name,
  rule({ t }) {
    return {
      type: name,
      field: uniqueId(),
      title: t("components.rate.name"),
      info: "",
      $required: false,
      props: {},
    };
  },
  props(_, { t }) {
    return localeProps(t, name + ".props", [
      makeRequiredRule(),
      {
        type: "inputNumber",
        field: "count",
        title: "评分的总数",
      },
      {
        type: "inputNumber",
        field: "max",
        title: "最大分值",
        props: { min: 0 },
      },
      {
        type: "switch",
        field: "readonly",
        title: "是否为只读",
      },
      {
        type: "switch",
        field: "allowHalf",
        title: "是否允许半选",
      },
      {
        type: "switch",
        field: "grading",
        title: "是否开启笑脸分级",
      },
    ]);
  },
};
